package com.example.demoexample.activity;

import android.os.Handler;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

import com.example.demoexample.R;
import com.example.demoexample.view.PullScrollView;

public class ScollActivity extends AppCompatActivity {

    private Handler handler;
    private PullScrollView test;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_scoll);


        final SwipeRefreshLayout swipeView = (SwipeRefreshLayout) findViewById(R.id.swipe);
        final TextView rndNum = (TextView) findViewById(R.id.rndNum);
//设置刷新颜色
        swipeView.setColorSchemeResources(android.R.color.holo_blue_light);
//设置刷新监听器
        swipeView.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                swipeView.setRefreshing(true);
                Log.d("Swipe", "Refreshing Number");
                //Handler更新界面，延时3000毫秒
                (new Handler()).postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        //设置刷新结束
                        swipeView.setRefreshing(false);
                        double f = Math.random();
                        rndNum.setText(String.valueOf(f));
                    }
                }, 3000);
            }
        });

    }

    private void init() {




    }














}
